home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* Check inactive channels *)
- (* *)
- (* Copyright 1988, 1989, 1990, 1991, 1992 by H. Roy Engehausen. All *)
- (* rights reserved. *)
- (* *)
- (*===========================================================================*)
-
- PROCEDURE check_inact;
-
- VAR
- clean_now : BOOLEAN;
- new_tcb : tcb_ptr;
- test_channel : BYTE;
-
-
- (*=========================================================================*)
- (* Subroutine to check an inactive port *)
- (*=========================================================================*)
-
- PROCEDURE check_inact_subr;
-
- VAR
- cvt_string : STRING[3];
-
- BEGIN;
-
- WITH active_port^, active_tcb^ DO
- BEGIN;
-
- (*-----------------------------------------------------------------*)
- (* Prep the TCB for polling sequence *)
- (*-----------------------------------------------------------------*)
-
- channel := test_channel;
- port_chan_s[2] := byte_to_char[test_channel];
-
- (*-----------------------------------------------------------------*)
- (* Execute the poll *)
- (*-----------------------------------------------------------------*)
-
- task_switch;
- send_recv_tnc(2);
-
- (*-----------------------------------------------------------------*)
- (* Process positive response. Verify proper type and start a *)
- (* new task if we can *)
- (*-----------------------------------------------------------------*)
-
- IF NOT tnc_null THEN
- BEGIN;
-
- t_str := port_chan_s + 'L:';
- window_write(t_str, tnc_data.str_data);
-
- IF tnc_type = t_to_h_links THEN
- BEGIN;
-
- new_tcb := task_create(@user_start, user_stack_size);
-
- IF new_tcb = NIL THEN
- BEGIN;
- window_write_critical(t_str,
- 'Out of tasks for a link status change');
- cmd_tnc(@disc_cmd, true);
- END;
-
- connected^[test_channel] := new_tcb;
-
- END
- ELSE
- BEGIN;
-
- IF tnc_type < SIZEOF(byte_to_char) THEN
- cvt_string := byte_to_char[tnc_type]
- ELSE
- STR(tnc_type, cvt_string);
-
- window_write_critical(t_str,
- 'DED host mode protocol error on INACT -- '
- + cvt_string);
-
- END;
-
- END; (*----- End not null processing ----------------------------*)
-
- (*-----------------------------------------------------------------*)
- (* Reset who we are *)
- (*-----------------------------------------------------------------*)
-
- port_chan_s[2] := '0';
- channel := 0;
-
- END; (*------- End active port addressing ---------------------------*)
-
- END;
-
- (*=========================================================================*)
- (* Main line *)
- (*=========================================================================*)
-
- BEGIN;
-
- WITH active_port^, active_tcb^ DO
- BEGIN;
-
- (*-------------------------------------------------------------------*)
- (* Bump the cleanup count and see if it is time *)
- (*-------------------------------------------------------------------*)
-
- INC(clean_count);
- clean_now := clean_count > 60;
-
- (*-------------------------------------------------------------------*)
- (* Set channel tester *)
- (*-------------------------------------------------------------------*)
-
- test_channel := 1;
-
- (*-------------------------------------------------------------------*)
- (* Loop thru the channels *)
- (*-------------------------------------------------------------------*)
-
- WHILE (test_channel <= max_chan) DO
- BEGIN;
-
- (*---------------------------------------------------------------*)
- (* If channel not connected, then test it *)
- (*---------------------------------------------------------------*)
-
- IF connected^[test_channel] = NIL THEN
- BEGIN;
-
- (*------------------------------------------------------------*)
- (* Check the channel *)
- (*------------------------------------------------------------*)
-
- check_inact_subr;
-
- (*------------------------------------------------------------*)
- (* If not in clean mode, we can leave *)
- (*------------------------------------------------------------*)
-
- IF NOT clean_now THEN
- EXIT;
-
- END;
-
- (*---------------------------------------------------------------*)
- (* Bump channel number *)
- (*---------------------------------------------------------------*)
-
- INC(test_channel);
-
- END; (*----- End channel loop -------------------------------------*)
-
- (*-------------------------------------------------------------------*)
- (* Reset clean counter if necessary *)
- (*-------------------------------------------------------------------*)
-
- IF clean_now THEN
- clean_count := 0;
-
- END; (*------- End active port addressing -----------------------------*)
-
- END;